package com.nlscan.qdkit.common.core.util

import com.nlscan.qdkit.common.core.util.RegexUtils

/**
 * <pre>
 *  author: lin.qing
 *  time  : 2023/4/10
 *  desc  :
 * </pre>
 */
object RegexExUtils {

    const val REGEX_PORT = "((6[0-4]\\d{3}|65[0-4]\\d{2}|655[0-2]\\d|6553[0-5])|[0-5]?\\d{0,4})"

    //    const val REGEX_DOMAIN = "^((?!-)[A-Za-z0-9-]{1,63}(?<!-)\\\\.)+[A-Za-z]{2,6}$"
    const val REGEX_DOMAIN = "^\\w+[^\\s]+(\\.[^\\s]+){1,}$"

    const val REGEX_HEX_STRING = "[0-9a-fA-F]*"

    fun isPort(input: String?): Boolean {
        return RegexUtils.isMatch(REGEX_PORT, input)
    }

    fun isDomain(input: String?): Boolean {
        return RegexUtils.isMatch(REGEX_DOMAIN, input)
    }

    fun isValidHexString(input: String): Boolean {
        return RegexUtils.isMatch(REGEX_HEX_STRING, input)
    }

}